//
//  UIView+STBWDirection.m
//  Pods-stoneobs_browser_Example
//
//  Created by imac on 2019/6/26.
//

#import "UIView+STBWDirection.h"

@implementation UIView (STBWDirection)
- (CGFloat)stbw_left {
    return self.frame.origin.x;
}

- (void)setStbw_left:(CGFloat)left {
    CGRect frame = self.frame;
    frame.origin.x = left;
    self.frame = frame;
}

- (CGFloat)stbw_top {
    return self.frame.origin.y;
}

- (void)setStbw_top:(CGFloat)top {
    CGRect frame = self.frame;
    frame.origin.y = top;
    self.frame = frame;
}

- (CGFloat)stbw_right {
    return self.frame.origin.x + self.frame.size.width;
}

- (void)setStbw_right:(CGFloat)right {
    CGRect frame = self.frame;
    frame.origin.x = right - frame.size.width;
    self.frame = frame;
}

- (CGFloat)stbw_bottom {
    return self.frame.origin.y + self.frame.size.height;
}

- (void)setStbw_bottom:(CGFloat)bottom {
    CGRect frame = self.frame;
    frame.origin.y = bottom - frame.size.height;
    self.frame = frame;
}

- (CGFloat)stbw_width {
    return self.frame.size.width;
}

- (void)setStbw_width:(CGFloat)width {
    CGRect frame = self.frame;
    frame.size.width = width;
    self.frame = frame;
}

- (CGFloat)stbw_height {
    return self.frame.size.height;
}

- (void)setStbw_height:(CGFloat)height {
    CGRect frame = self.frame;
    frame.size.height = height;
    self.frame = frame;
}

- (CGPoint)stbw_origin {
    return self.frame.origin;
}

- (void)setStbw_origin:(CGPoint)origin {
    CGRect frame = self.frame;
    frame.origin = origin;
    self.frame = frame;
}

- (CGSize)stbw_size {
    return self.frame.size;
}

- (void)setStbw_size:(CGSize)size {
    CGRect frame = self.frame;
    frame.size = size;
    self.frame = frame;
}
- (void)setStbw_centerX:(CGFloat)centerX
{
    CGPoint center = self.center;
    center.x = centerX;
    self.center = center;
}

- (CGFloat)stbw_centerX
{
    return self.center.x;
}

- (void)setStbw_centerY:(CGFloat)centerY
{
    CGPoint center = self.center;
    center.y = centerY;
    self.center = center;
}

- (CGFloat)stbw_centerY
{
    return self.center.y;
}

- (void)stbw_setBorderWith:(CGFloat)width borderColor:(UIColor *)borderColor cornerRadius:(CGFloat)radius{
    self.layer.borderColor = borderColor.CGColor;
    self.layer.borderWidth = width;
    self.layer.cornerRadius = radius;
    self.clipsToBounds = YES;
}
@end
